Open
Conversation
jjunhub
reviewed
Oct 26, 2024
Comment on lines
45
to
56
| // TODO : 회원 이름으로 회원 정보를 조회한다. | ||
| public List<MemberResponse> searchMembersWithName(String memberName) { | ||
| // DB에서 memberName에 해당하는 회원 정보를 조회한다. | ||
| List<Member> members = memberRepository.findByMemberName(memberName); | ||
| if(members==null) | ||
| throw new IllegalArgumentException("해당 회원이 없어여"); | ||
|
|
||
| // 조회된 회원 정보를 List<MemberResponse>로 변환하여 반환한다. | ||
| return null; | ||
| return members.stream() | ||
| .map(MemberResponse::from) | ||
| .toList(); | ||
| } |
Member
There was a problem hiding this comment.
요 부분 꼼꼼하게 체크하는 것도 좋습니다!
여기서 한 가지 생각해보아야할 것이 있습니다.
지금은 회원 이름으로 회원 정보를 조회 요청하였는데 이에 대한 결과가 없는 상황입니다.
- 예외를 발생시키는 것이 프론트가 처리하기 편할 지
- 빈 리스트를 내려주는 것이 프론트가 처리하기 편할 지
고민해보시면 좋을 것 같습니다.
저는 2번쪽으로 해주는 것이 편하다고 생각하고, 프론트 분들도 편하다고 해서 아래처럼 빈 것인지 체크하지 않고 바로 내려주는 쪽으로 진행했습니다.
참고하시면 될 것 같아요!
Suggested change
| // TODO : 회원 이름으로 회원 정보를 조회한다. | |
| public List<MemberResponse> searchMembersWithName(String memberName) { | |
| // DB에서 memberName에 해당하는 회원 정보를 조회한다. | |
| List<Member> members = memberRepository.findByMemberName(memberName); | |
| if(members==null) | |
| throw new IllegalArgumentException("해당 회원이 없어여"); | |
| // 조회된 회원 정보를 List<MemberResponse>로 변환하여 반환한다. | |
| return null; | |
| return members.stream() | |
| .map(MemberResponse::from) | |
| .toList(); | |
| } | |
| // TODO : 회원 이름으로 회원 정보를 조회한다. | |
| public List<MemberResponse> searchMembersWithName(String memberName) { | |
| // DB에서 memberName에 해당하는 회원 정보를 조회한다. | |
| List<Member> members = memberRepository.findByMemberName(memberName); | |
| // 조회된 회원 정보를 List<MemberResponse>로 변환하여 반환한다. | |
| return members.stream() | |
| .map(MemberResponse::from) | |
| .toList(); | |
| } |
jjunhub
reviewed
Oct 26, 2024
Comment on lines
+73
to
+74
| if(member.isEmpty()) | ||
| throw new IllegalArgumentException("넌 무슨 이름을 바꾼다는 말을"); |
jjunhub
reviewed
Oct 26, 2024
| Optional<Member> member = memberRepository.findById(memberId); | ||
| if(member.isEmpty()) | ||
| throw new IllegalArgumentException("넌 무슨 이름을 바꾼다는 말을"); | ||
| member.get().changeName(request.getNewname()); |
Member
There was a problem hiding this comment.
요 부분도 아까 보내드린 블로그 링크 참고하셔서 orElseThrow() 쓰는 쪽으로 수정해보시면 좋을 것 같네요!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
로그인 성공
비번 바꾸기 실패
response


log